package com.macro.mall.portal.controller;

import com.github.pagehelper.PageInfo;
import com.macro.mall.model.SapAccount;
import com.macro.mall.portal.service.SapAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Log4j2
@RestController
@Api(tags = "SapAccountController", description = "门户：账户管理")
@RequestMapping("/account")
public class SapAccountController {
    @Autowired
    private SapAccountService sapAccountServiceImpl;

    @ApiOperation("获取账户信息")
    @RequestMapping(value = "/getAccountList", method = RequestMethod.GET)
    private PageInfo<SapAccount> getSapAccountList(@RequestParam(value = "memberId") Long memberId) {
        return sapAccountServiceImpl.getSapAccountList(memberId);
    }

    @ApiOperation("提取账户余额")
    @RequestMapping(value = "/extractSapAccount", method = RequestMethod.GET)
    private void extractSapAccount(@RequestParam(value = "memberId") Long memberId,@RequestParam(value = "balance", defaultValue = "提取金额") String balance){
        sapAccountServiceImpl.extractSapAccount(memberId,balance,"2");
    }

    @ApiOperation("提取账户余额审批")
    @RequestMapping(value = "/vertifyApply", method = RequestMethod.GET)
    private void vertifyApply(@RequestParam(value = "memberId") Long memberId,@RequestParam(value = "balance", defaultValue = "提取金额") String status){
        sapAccountServiceImpl.vertifyApply(memberId,status);
    }
}
